package p7;

/**
 * @author krystal
 * @date 2022/11/11 22:57
 */
class Person{
    public String name;
    public int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public void eat(){
        System.out.println(name+"在吃饭");
    }
}

class Superstar extends Person{
    public Superstar(String name, int age) {
        super(name, age);
    }

    public void eat(){
        System.out.println(name+"在吃酱骨头");
    }

    public void sing(){
        System.out.println(name+"在唱自己发行的歌");
    }
}

public class Demo6 {
    public static void main(String[] args) {
        Person person=new Superstar("baekhyun",30);
        if(person instanceof Superstar){
            Superstar superstar=(Superstar) person;
            superstar.sing();
        }
    }
}